package com.zhang.backend.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zhang.backend.model.domain.Product;
import com.zhang.backend.mapper.ProductMapper;
import com.zhang.backend.service.ProductService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author zyx
 * @since 2021-12-22
 */
@Service
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements ProductService {

    @Override
    public List<Product> productList() {
        QueryWrapper<Product> wrapper = new QueryWrapper<>();
        return baseMapper.selectList(wrapper);
    }

    @Override
    public List<Product> selectById(Product product) {
//        List<Product> list = productList();
//        List<Product> collect = list.stream().filter(x -> x.getPname().equals(product.getPname())).collect(Collectors.toList());
        QueryWrapper<Product> wrapper = new QueryWrapper<>();
        wrapper.lambda().like(Product::getPname, product.getPname());
        return baseMapper.selectList(wrapper);
    }
}
